<style>
	.weui_icon_area img{
		width:120px;
		height:120px;
		border-radius: 60px;
	}
</style>
<div class="page slideIn msg">
    <div class="weui_msg">
        <div class="weui_icon_area">
        	<img src="{php echo $user['avatar']}" alt="" />
        </div>
        <div class="weui_text_area">
            <h2 class="weui_msg_title">{$user['nickname']}</h2>
            <p class="weui_msg_desc">
            	{$order['desc']}
            </p>
        </div>
        <div class="weui_opr_area">
            <p class="weui_btn_area">
            	{if $order['status'] == 1}
            		<a href="javascript:;" class="weui_btn weui_btn_primary" data-id="{$order['id']}" id="reciveOrder">立即接单</a>
            	{else}
                	<a href="javascript:;" class="weui_btn weui_btn_default" >已被抢</a>
                {/if}
                <a href="javascript:;" id="voice" data-id="{$order['media_id']}" class="weui_btn weui_btn_warn">立即播放</a>
                <a href="{php echo $this->createMobileUrl('index')}" class="weui_btn weui_btn_default">返回</a>
            </p>
        </div>
    </div>
</div>

<script>
require(['jquery','core','weixin'],function($,core,wx){
	wx.config(jssdkconfig);
	$('#footer').show();
	$('.weui_btn_default').click(function(){
		window.history.go(-1);
	});
	var voicing = false;
	var localId = null;
	
	$('#voice').click(function(){
		var media_id = $(this).data('id');
		wx.ready(function(){
			if(core.empty(localId)){
				wx.downloadVoice({
				    serverId: media_id,
				    isShowProgressTips: 1,
				    success: function (res) {
				        localId = res.localId;
				        //播放
				        wx.playVoice({
				            localId: localId
				        });
				        //清除定时器
				        wx.onVoicePlayEnd({
				        	success:function(){
				        		voicing = false;
				        	},
				        	fail:function(){
				        		
				        	}
				        });
				    },
				    fail:function(){
				    	voicing = false;
		        	}
				});
			}else{
				wx.playVoice({
		            localId: localId
		        });
		        //清除定时器
		        wx.onVoicePlayEnd({
		        	success:function(){
		        		voicing = false;
		        	},
		        	fail:function(){
		        		
		        	}
		        });
			}
		});
	});
	
	$('#reciveOrder').click(function(){
		core.post('reciveorder',{id:$(this).data('id')},function(data){
			if(data.success == 0){
				core.ok(data.message,function(){
					$.pjax({
						url:"{php echo $this->createMobileUrl('recive')}&id="+data.id,
						container:"#pjax-container"
					});
				});
			}else{
				core.cancel(data.message,function(){
					
				});
			}
			
		});
	});
});
</script>
{template 'default/common/share'}